package com.fsbm.ctech.maxis.ebpsbackend;

import java.io.*;
import java.text.*;
import java.util.*;
import java.util.Date;
import java.util.Properties;
/**
 * Configuration File Object and Logger for Email, SMS notification, Subscription
 * and Adhoc Bill Delivery. It is also used by the batch update programs
 * <p>
 * Maxis Backend Program - Configuration Object to load the config properties file.
 *
 * @author Michael Ty Chan
 */

class ConfigObject { //implements Serializable{

    public String stageDirectory;             // where all the CSV files newly created were dump
    public String workDirectory;              // where all the CSV files newly created were dump
    public String smsInDirectory;             // where all the new SMS files go in
    public String smsOutDirectory;            // where all the sent SMS files is transferred after processing
    public String smsTempDirectory;           // where all the temp SMS files is transferred after processing

    public String emailFileList;              // email notification file name
    public String smsFileList;                // sms notificaiton file name
    public String smsTempFileList;            // sms notificaiton temp file name

    public String merchantName;               // merchant to be processed

    public String emailHeader1;               // Headers for the Email Notification CSV file
    public String emailHeader2;               // Header 2
    public String emailHeader3;               // Header 3
    public String emailHeader4;               // Header 4
    public String emailHeader5;               // Header 5
    public String emailHeader6;               // Header 6
    public String emailHeader7;               // Header 7
    
    //Start Adding by Khang - for generating bill url
    public String emailHeader8;               // 
    public String billUrl;
    public String privateKeyFile;			  // RSA key
    public String privateKeyPass;
    public String secretKeyFile;			  // AES key
    public String billImageFile;			  // 
    public String billUrlTimeFormat;
    //End Adding by Khang
    
    public String SMSServerRefNo;             // SMS message mapped in the SMS Gateway

    public String listingErrorFile;           // Error Listing of online events

    public String notifyEmailTemplate;        // Template file to be used for notification
    public String notifyEmailCommand;         // Command file to be used for notification
    public String notifyTemplateDirectory;    // directory where the templates resides
    public String zipToTransferDirectory;     // directory where the zip files are to be transferred for ftp
    public String zipFileName;                // file name of zip file created
    public String tempDirectory;              // where all the garbage go

    public String notifyEmailBodyFileName;    // name of the actual file
    public String notifyEmailCommandFileName; // name of the actual coimmand file

    public String databaseDriver;             // database driver used by GetStatementIds(getStmtIds) and Update.class
    public String databaseSourceName;         // database source name
    public String databaseUserID;             // database user id
    public String databasePassword;           // database password

    public String ftpSMTPUser;                // ftp user id for SMTP server
    public String ftpSMTPPassword;            // ftp user password
    public String ftpSMTPAddress;             // ftp IP Address (Destination of the zip files for sending)
    public String ftpSMTPType;             	  // ftp type (get/put)
    public String ftpSMTPLocalDirectory;      // ftp local directory
    public String ftpSMTPRemoteDirectory;     // ftp remote directory

    public String ftpAdhocSMTPUser;                // ftp user id for Adhoc SMTP server
    public String ftpAdhocSMTPPassword;            // ftp Adhoc user password
    public String ftpAdhocSMTPAddress;             // ftp Adhoc IP Address (Destination of the zip files for sending)
    public String ftpAdhocSMTPType;                // ftp Adhoc type (get/put)
    public String ftpAdhocSMTPLocalDirectory;      // ftp Adhoc local directory
    public String ftpAdhocSMTPRemoteDirectory;     // ftp Adhoc remote directory
    public String ftpAdhocSMTPLocalTempDirectory;      // ftp Adhoc local temp directory

    public String ftpSMTPUpdateAddress;       // ftp IP Address (Source where to get the updated MBX files)
    public String ftpSMTPUpdateUser;          // ftp user for the retrieval of updated MBX files
    public String ftpSMTPUpdatePassword;      // ftp user password for the retrieval of updated MBX files

    public String ftpSMSAddress;              // SMS Server gateway address (Destination of the '*.vub' files)
    public String ftpSMSUser;                 // SMS Server gateway User name
    public String ftpSMSPassword;             // SMS Server gateway User password


    public String pdfStageDirectory;          // subs delivery staging directory (where all files(CSVs & PDFs) are created at the same time)
    public String pdfWorkDirectory;           // subs delivery work directory (where each CSV file is move with its PDFs, created body/cmd)
    public String pdfEmailFileList;           // subs delivery path plus the filename prefix (path name + SU)
    public String pdfTransferDirectory;       // subs delivery (path where all files from work dir are transferred after zipping - ready 4 transfer)
    public String pdfTempDirectory;           // subs delivery (where all garbage goes after creating, zipping and transferring the files)

    public String pdfTemplateDirectory;       // path where the subscription delivery template resides (body.txt)
    public String pdfEmailBodyFileName;       // name of the subscription delivery body file template
    public String pdfEmailCommandFileName;    // name of the subscription delivery command file template
    public String pdfEmailTemplate;           // do not use the word 'List' or '.csv' Delivery subscriber absolute path and file of template
    public String pdfEmailCommand;            // do not use the word 'List' or '.csv' Delivery subscriber absolute path and file of command
    public String zipSubsFileName;            // file name of zip file created for bill delivery subscription

    public String pdfAdStageDirectory;        // adhoc delivery staging directory (where all files(CSVs & PDFs) are created at the same time)
    public String pdfAdWorkDirectory;         // adhoc delivery work directory (where each CSV file is move with its PDFs, created body/cmd)
    public String pdfAdEmailFileList;         // adhoc delivery path plus the filename prefix (path name + AD)
    public String pdfAdTransferDirectory;     // adhoc delivery (path where all files from work dir are transferred after zipping - ready 4 transfer)
    public String pdfAdTempDirectory;         // adhoc delivery (where all garbage goes after creating, zipping and transferring the files)

    public String pdfAdTemplateDirectory;     // path where the adhoc delivery template resides (body.txt)
    public String pdfAdEmailBodyFileName;     // name of the adhoc delivery body file template
    public String pdfAdEmailCommandFileName;  // name of the adhoc delivery command file template
    public String pdfAdEmailTemplate;         // do not use the word 'List' or '.csv' Adhoc subscriber absolute path and file of template
    public String pdfAdEmailCommand;          // do not use the word 'List' or '.csv' Adhoc subscriber absolute path and file of command
    public String zipAdhocFileName;           // file name of zip file created for bill delivery subscription

    public String transferAfterZIPCreate;     // * Undocumented feature * a value of yes for this two will hold all the files created
                                              // in the transfer directory this is applicable for Email Notification/Adhoc/Subscription Delivery
    public String logFile;                    // this is where all the Common.YYY-MM-DD.log resides
    public String getSMTPmbx;                 // instruction to ftp back mbx files

    public String smtpUpdateDirectory;        // path where all the MBX files are auto tranferred from the SMTP server locally
    public String doneSMTPDirectory;          // path where all the processed MBX files are moved after updating the EBPS database on the status

    //Lendy start
    public int maxPerEmailCSV;
    public int maxPerSMSCSV;
    public int maxNotifyRowPerCSV;
    public int maxSubsRowPerCSV;
    public int maxFileAmount;
    public int maxSMSRowPerVUB;

    public String reprintStageDirectory;
    public String reprintWorkDirectory;
    public String reprintTransferDirectory;
    public String reprintTempDirectory;

    public int maxReprintRowPerCSV;

    public String reprintTitle;                 // Title

    public String reprintHeader1;               // Headers for the Reprint CSV file
    public String reprintHeader2;               // Header 2
    public String reprintHeader3;               // Header 3
    public String reprintHeader4;               // Header 4

    public String reprintFooter1;               // Footers for the Reprint CSV file

    public String ftpReprintAddress;       // ftp IP Address
    public String ftpReprintUser;          // ftp user
    public String ftpReprintPassword;      // ftp user password

    public String ftpReprintDestinationDirectory;

    //Lendy end

   	//Poon Start
    public String ftpSSHReprintAddress;       // SSHftp IP Address
    public String ftpSSHReprintUser;          // SSHftp user
    public String ftpSSHReprintPassword;      // SSHftp user password
    public String ftpSSHPrivateKeyFile;       // SSHftp Private Key File
   	public String ftpSSHPassphrase;           // SSHftp Passphrase
   	public String ftpSSHReprintDestinationDirectory;
   	//Poon End

//ZipAndLoad Start
    public String zipAndLoad_ZIP_InDirectory;
    public String zipAndLoad_ZIP_OutDirectory;
    public String zipAndLoad_ZIP_DoneDirectory;
    public String zipAndLoad_ZIP_ErrorDirectory;

	public String zipAndLoad_LOAD_InDirectory;
	public String zipAndLoad_LOAD_OutDirectory;
	public String zipAndLoad_LOAD_DoneDirectory;
	public String zipAndLoad_LOAD_ErrorDirectory;

	public boolean zipAndLoad_Debug_On;

	public String zipAndLoad_DB_User;
	public String zipAndLoad_DB_Password;
	public String zipAndLoad_DB_URL;

	// Added by Meau
	public String CORPCUST_TMP_FILE_NAME;

//ZipAndLoad End

//AstroMSC start
    public String AstroMSC_InDirectory;
    public String AstroMSC_OutDirectory;
    public String AstroMSC_DoneDirectory;
    public String AstroMSC_ErrorDirectory;
//AstroMSC End

// MAPS Start
	public String maps_OutDirectory;
	public String maps_TemplateDirectory;
	public String maps_TemplateName;
	public String maps_CIMB_TemplateName;
	public String maps_ReportHeading;
	public double serviceTaxRate;
	public boolean maps_Debug_On;
// MAPS End

// SCB Start
	public String scb_OutDirectory;
	public String scb_TemplateDirectory;
	public String scb_TemplateName;
	public String scb_ReportHeading;
	public boolean scb_Debug_On;
	public String scb_country_code;
	public String scb_carrier_code;
// SCB End

    public ConfigObject(){
        try{
            // Open input/output and setup variables
            Properties env = getEnvironment();
            String cfiPath = env.getProperty("BGROOT");

            FileInputStream fis     = new FileInputStream(cfiPath+"/java/config.property");
            Properties p            = new Properties();
            p.load(fis);
            fis.close();

            //Lendy start
            if (p.getProperty("maxPerEmailCSV")==null || p.getProperty("maxPerEmailCSV").equals("")){
                maxPerEmailCSV = 100;
            } else{
                maxPerEmailCSV = Integer.parseInt(p.getProperty("maxPerEmailCSV").trim());
            }

            if (p.getProperty("maxPerSMSCSV")==null || p.getProperty("maxPerSMSCSV").equals("")){
                maxPerSMSCSV = 100;
            } else{
                maxPerSMSCSV = Integer.parseInt(p.getProperty("maxPerSMSCSV").trim());
            }
            if (p.getProperty("maxSMSRowPerVUB")==null || p.getProperty("maxSMSRowPerVUB").equals("")){
                maxSMSRowPerVUB = 100;
            } else{
                maxSMSRowPerVUB = Integer.parseInt(p.getProperty("maxSMSRowPerVUB").trim());
            }
            if (p.getProperty("maxSubsRowPerCSV")==null || p.getProperty("maxSubsRowPerCSV").equals("")){
                maxSubsRowPerCSV = 500;
            } else{
                maxSubsRowPerCSV = Integer.parseInt(p.getProperty("maxSubsRowPerCSV").trim());
            }
            if (p.getProperty("maxNotifyRowPerCSV")==null || p.getProperty("maxNotifyRowPerCSV").equals("")){
                maxNotifyRowPerCSV = 500;
            } else{
                maxNotifyRowPerCSV = Integer.parseInt(p.getProperty("maxNotifyRowPerCSV").trim());
            }
            if (p.getProperty("maxFileAmount")==null || p.getProperty("maxFileAmount").equals("")){
                maxFileAmount = 100;
            } else{
                maxFileAmount = Integer.parseInt(p.getProperty("maxFileAmount").trim());
            }
            //Lendy end

            // please refer to the comments above on the following parameters set by the java property class
            merchantName       = p.getProperty("merchantName").trim();

            emailHeader1       = p.getProperty("emailHeader1").trim();
            emailHeader2       = p.getProperty("emailHeader2").trim();
            emailHeader3       = p.getProperty("emailHeader3").trim();
            emailHeader4       = p.getProperty("emailHeader4").trim();
            emailHeader5       = p.getProperty("emailHeader5").trim();
            emailHeader6       = p.getProperty("emailHeader6").trim();
            emailHeader7       = p.getProperty("emailHeader7").trim();
            //Start adding by Khang
            emailHeader8        = p.getProperty("emailHeader8").trim();
            billUrl       		= p.getProperty("billUrl").trim();
            privateKeyFile      = p.getProperty("privateKeyFile").trim();
            privateKeyPass      = p.getProperty("privateKeyPass").trim();
            secretKeyFile       = p.getProperty("secretKeyFile").trim();
            billImageFile       = p.getProperty("billImageFile").trim();
            billUrlTimeFormat       = p.getProperty("billUrlTimeFormat").trim();
            //End adding by Khang

            SMSServerRefNo     = p.getProperty("SMSServerRefNo").trim();

            //PDF Delivery - Subscription Specific
            pdfStageDirectory       = p.getProperty("pdfStageDirectory").trim();
            pdfWorkDirectory        = p.getProperty("pdfWorkDirectory").trim();
            pdfTransferDirectory    = p.getProperty("pdfTransferDirectory").trim();
            pdfTempDirectory        = p.getProperty("pdfTempDirectory").trim();
            pdfEmailFileList        = p.getProperty("pdfEmailFileList").trim();         // last word of filename should be 'List'
            pdfTemplateDirectory    = p.getProperty("pdfTemplateDirectory").trim();
            pdfEmailBodyFileName    = p.getProperty("pdfEmailBodyFileName").trim();
            pdfEmailCommandFileName = p.getProperty("pdfEmailCommandFileName").trim();
            pdfEmailTemplate        = p.getProperty("pdfEmailTemplate").trim();         // do not use the word 'List' or '.csv'
            pdfEmailCommand         = p.getProperty("pdfEmailCommand").trim();          // do not use the word 'List' or '.csv'
            zipSubsFileName         = p.getProperty("zipSubsFileName").trim();                                        // file name of zip file created for bill delivery subscription
            //PDF Delivery - Adhoc Specific
            pdfAdStageDirectory        = p.getProperty("pdfAdStageDirectory").trim();
            pdfAdWorkDirectory         = p.getProperty("pdfAdWorkDirectory").trim();
            pdfAdTransferDirectory     = p.getProperty("pdfAdTransferDirectory").trim();
            pdfAdTempDirectory         = p.getProperty("pdfAdTempDirectory").trim();
            pdfAdEmailFileList         = pdfAdStageDirectory + "AD";                     // last word of filename should be 'List'
            pdfAdTemplateDirectory     = p.getProperty("pdfAdTemplateDirectory").trim();
            pdfAdEmailBodyFileName     = p.getProperty("pdfAdEmailBodyFileName").trim();
            pdfAdEmailCommandFileName  = p.getProperty("pdfAdEmailCommandFileName").trim();
            pdfAdEmailTemplate         = p.getProperty("pdfAdEmailTemplate").trim();    // do not use the word 'List' or '.csv'
            pdfAdEmailCommand          = p.getProperty("pdfAdEmailCommand").trim();     // do not use the word 'List' or '.csv'
            zipAdhocFileName           = p.getProperty("zipAdhocFileName").trim();                                              // file name of zip file created for bill delivery subscription
            // SMS and Email Notification Specific
            stageDirectory             = p.getProperty("stageDirectory").trim();
            workDirectory              = p.getProperty("workDirectory").trim();
            zipToTransferDirectory     = p.getProperty("zipToTransferDirectory").trim();
            tempDirectory              = p.getProperty("tempDirectory").trim();
            smsInDirectory             = p.getProperty("smsInDirectory").trim();
            smsOutDirectory            = p.getProperty("smsOutDirectory").trim();
            smsTempDirectory            = p.getProperty("smsTempDirectory").trim();
            emailFileList              = stageDirectory + "EmailNotifyList";
            smsFileList                = smsInDirectory + "SMSNotifyList";
            smsTempFileList             = smsTempDirectory + "SMSNotifyList";
            zipFileName                = p.getProperty("zipFileName").trim();
            notifyTemplateDirectory    = p.getProperty("notifyTemplateDirectory").trim();
            notifyEmailBodyFileName    = p.getProperty("notifyEmailBodyFileName").trim();
            notifyEmailCommandFileName = p.getProperty("notifyEmailCommandFileName").trim();
            notifyEmailTemplate        = p.getProperty("notifyEmailTemplate").trim();
            notifyEmailCommand         = p.getProperty("notifyEmailCommand").trim();
            listingErrorFile           = p.getProperty("listingErrorFile").trim();
            databaseDriver             = p.getProperty("databaseDriver").trim();
            databaseSourceName         = p.getProperty("databaseSourceName").trim();
            databaseUserID             = p.getProperty("databaseUserID").trim();
            databasePassword           = p.getProperty("databasePassword").trim();
            ftpSMTPAddress             = p.getProperty("ftpSMTPAddress").trim();
            ftpSMTPUser                = p.getProperty("ftpSMTPUser").trim();
            ftpSMTPPassword            = p.getProperty("ftpSMTPPassword").trim();
            ftpSMTPType                = p.getProperty("ftpSMTPType").trim();
            ftpSMTPLocalDirectory      = p.getProperty("ftpSMTPLocalDirectory").trim();
            ftpSMTPRemoteDirectory     = p.getProperty("ftpSMTPRemoteDirectory").trim();

            ftpAdhocSMTPAddress             = p.getProperty("ftpAdhocSMTPAddress").trim();
            ftpAdhocSMTPUser                = p.getProperty("ftpAdhocSMTPUser").trim();
            ftpAdhocSMTPPassword            = p.getProperty("ftpAdhocSMTPPassword").trim();
            ftpAdhocSMTPType                = p.getProperty("ftpAdhocSMTPType").trim();
            ftpAdhocSMTPLocalDirectory      = p.getProperty("ftpAdhocSMTPLocalDirectory").trim();
            ftpAdhocSMTPRemoteDirectory     = p.getProperty("ftpAdhocSMTPRemoteDirectory").trim();
            ftpAdhocSMTPLocalTempDirectory      = p.getProperty("ftpAdhocSMTPLocalTempDirectory").trim();

            ftpSMTPUpdateAddress       = p.getProperty("ftpSMTPUpdateAddress").trim();
            ftpSMTPUpdateUser          = p.getProperty("ftpSMTPUpdateUser").trim();
            ftpSMTPUpdatePassword      = p.getProperty("ftpSMTPUpdatePassword").trim();
            ftpSMSAddress              = p.getProperty("ftpSMSAddress").trim();
            ftpSMSUser                 = p.getProperty("ftpSMSUser").trim();
            ftpSMSPassword             = p.getProperty("ftpSMSPassword").trim();
            logFile                    = p.getProperty("logFile").trim();
            transferAfterZIPCreate     = p.getProperty("transferAfterZIPCreate").trim();
            getSMTPmbx                 = p.getProperty("getSMTPmbx").trim();
            smtpUpdateDirectory        = p.getProperty("smtpUpdateDirectory").trim();
            doneSMTPDirectory          = p.getProperty("doneSMTPDirectory").trim();

            //Lendy start
            reprintStageDirectory       = p.getProperty("reprintStageDirectory").trim();
            reprintWorkDirectory        = p.getProperty("reprintWorkDirectory").trim();
            reprintTransferDirectory    = p.getProperty("reprintTransferDirectory").trim();
            reprintTempDirectory        = p.getProperty("reprintTempDirectory").trim();

            if (p.getProperty("maxReprintRowPerCSV")==null || p.getProperty("maxReprintRowPerCSV").equals("")){
                maxReprintRowPerCSV = 100;
            } else{
                maxReprintRowPerCSV = Integer.parseInt(p.getProperty("maxReprintRowPerCSV").trim());
            }

            reprintTitle       = p.getProperty("reprintTitle").trim();

            reprintHeader1       = p.getProperty("reprintHeader1").trim();
            reprintHeader2       = p.getProperty("reprintHeader2").trim();
            reprintHeader3       = p.getProperty("reprintHeader3").trim();
            reprintHeader4       = p.getProperty("reprintHeader4").trim();

            reprintFooter1       = p.getProperty("reprintFooter1").trim();

            ftpReprintAddress              = p.getProperty("ftpReprintAddress").trim();
            ftpReprintUser                 = p.getProperty("ftpReprintUser").trim();
            ftpReprintPassword             = p.getProperty("ftpReprintPassword").trim();

            ftpReprintDestinationDirectory  = p.getProperty("ftpReprintDestinationDirectory").trim();

            //Lendy end

            //Poon start
    		ftpSSHReprintAddress = p.getProperty("ftpSSHReprintAddress").trim();
    		ftpSSHReprintUser = p.getProperty("ftpSSHReprintUser").trim();
    		ftpSSHReprintPassword = p.getProperty("ftpSSHReprintPassword").trim();
    		ftpSSHPrivateKeyFile = p.getProperty("ftpSSHPrivateKeyFile").trim();
   			ftpSSHPassphrase = p.getProperty("ftpSSHPassphrase").trim();
   			ftpSSHReprintDestinationDirectory  = p.getProperty("ftpSSHReprintDestinationDirectory").trim();
            //Poon end

//ZipAndLoad Start

			//ZIP
            if (p.getProperty("zipAndLoad_ZIP_InDirectory")==null || p.getProperty("zipAndLoad_ZIP_InDirectory").equals("")){
                zipAndLoad_ZIP_InDirectory = "";
            } else{
                zipAndLoad_ZIP_InDirectory = p.getProperty("zipAndLoad_ZIP_InDirectory").trim();
            }

            if (p.getProperty("zipAndLoad_ZIP_OutDirectory")==null || p.getProperty("zipAndLoad_ZIP_OutDirectory").equals("")){
                zipAndLoad_ZIP_OutDirectory = "";
            } else{
                zipAndLoad_ZIP_OutDirectory = p.getProperty("zipAndLoad_ZIP_OutDirectory").trim();
            }

            if (p.getProperty("zipAndLoad_ZIP_DoneDirectory")==null || p.getProperty("zipAndLoad_ZIP_DoneDirectory").equals("")){
                zipAndLoad_ZIP_DoneDirectory = "";
            } else{
                zipAndLoad_ZIP_DoneDirectory = p.getProperty("zipAndLoad_ZIP_DoneDirectory").trim();
            }

            if (p.getProperty("zipAndLoad_ZIP_ErrorDirectory")==null || p.getProperty("zipAndLoad_ZIP_ErrorDirectory").equals("")){
                zipAndLoad_ZIP_ErrorDirectory = "";
            } else{
                zipAndLoad_ZIP_ErrorDirectory = p.getProperty("zipAndLoad_ZIP_ErrorDirectory").trim();
            }

			//LOAD
            if (p.getProperty("zipAndLoad_LOAD_InDirectory")==null || p.getProperty("zipAndLoad_LOAD_InDirectory").equals("")){
                zipAndLoad_LOAD_InDirectory = "";
            } else{
                zipAndLoad_LOAD_InDirectory = p.getProperty("zipAndLoad_LOAD_InDirectory").trim();
            }

            if (p.getProperty("zipAndLoad_LOAD_OutDirectory")==null || p.getProperty("zipAndLoad_LOAD_OutDirectory").equals("")){
                zipAndLoad_LOAD_OutDirectory = "";
            } else{
                zipAndLoad_LOAD_OutDirectory = p.getProperty("zipAndLoad_LOAD_OutDirectory").trim();
            }

            if (p.getProperty("zipAndLoad_LOAD_DoneDirectory")==null || p.getProperty("zipAndLoad_LOAD_DoneDirectory").equals("")){
                zipAndLoad_LOAD_DoneDirectory = "";
            } else{
                zipAndLoad_LOAD_DoneDirectory = p.getProperty("zipAndLoad_LOAD_DoneDirectory").trim();
            }

            if (p.getProperty("zipAndLoad_LOAD_ErrorDirectory")==null || p.getProperty("zipAndLoad_LOAD_ErrorDirectory").equals("")){
                zipAndLoad_LOAD_ErrorDirectory = "";
            } else{
                zipAndLoad_LOAD_ErrorDirectory = p.getProperty("zipAndLoad_LOAD_ErrorDirectory").trim();
            }

            String strTempVal = p.getProperty("zipAndLoad_Debug_On").toLowerCase();
            strTempVal = strTempVal.trim();

			if (strTempVal!=null && strTempVal.equals("yes")){
				zipAndLoad_Debug_On = true;
			} else{
				zipAndLoad_Debug_On = false;
			}

			//Database Connection
            if (p.getProperty("zipAndLoad_DB_User")==null || p.getProperty("zipAndLoad_DB_User").equals("")){
                zipAndLoad_DB_User = "";
            } else{
                zipAndLoad_DB_User = p.getProperty("zipAndLoad_DB_User").trim();
            }

            if (p.getProperty("zipAndLoad_DB_Password")==null || p.getProperty("zipAndLoad_DB_Password").equals("")){
                zipAndLoad_DB_Password = "";
            } else{
                zipAndLoad_DB_Password = p.getProperty("zipAndLoad_DB_Password").trim();
            }

            if (p.getProperty("zipAndLoad_DB_URL")==null || p.getProperty("zipAndLoad_DB_URL").equals("")){
                zipAndLoad_DB_URL = "";
            } else{
                zipAndLoad_DB_URL = p.getProperty("zipAndLoad_DB_URL").trim();
            }

            if (p.getProperty("CORPCUST_TMP_FILE_NAME")==null || p.getProperty("CORPCUST_TMP_FILE_NAME").equals("")){
                CORPCUST_TMP_FILE_NAME = "";
            } else{
                CORPCUST_TMP_FILE_NAME = p.getProperty("CORPCUST_TMP_FILE_NAME").trim();
            }
//ZipAndLoad End

//MAPS Start
            if (p.getProperty("maps_OutDirectory")==null || p.getProperty("maps_OutDirectory").equals("")){
                maps_OutDirectory = ".";
            } else{
                maps_OutDirectory = p.getProperty("maps_OutDirectory").trim();
            }

            if (p.getProperty("maps_TemplateDirectory")==null || p.getProperty("maps_TemplateDirectory").equals("")){
                maps_TemplateDirectory = ".";
            } else{
                maps_TemplateDirectory = p.getProperty("maps_TemplateDirectory").trim();
            }

            if (p.getProperty("maps_TemplateName")==null || p.getProperty("maps_TemplateName").equals("")){
                maps_TemplateName = "";
            } else{
                maps_TemplateName = p.getProperty("maps_TemplateName").trim();
            }

            if (p.getProperty("maps_CIMB_TemplateName")==null || p.getProperty("maps_CIMB_TemplateName").equals("")){
                maps_CIMB_TemplateName = "";
            } else{
                maps_CIMB_TemplateName = p.getProperty("maps_CIMB_TemplateName").trim();
            }

            if (p.getProperty("maps_ReportHeading")==null || p.getProperty("maps_ReportHeading").equals("")){
                maps_ReportHeading = "MONTHLY ACCOUNT SUMMARY FOR THE MONTH OF <MMM - yyyy>";
            } else{
                maps_ReportHeading = p.getProperty("maps_ReportHeading").trim();
            }

            if (p.getProperty("maps_ServiceTaxRate")==null || p.getProperty("maps_ServiceTaxRate").equals("")){
                serviceTaxRate = 0.06;
            } else{
                serviceTaxRate = Double.parseDouble(p.getProperty("maps_ServiceTaxRate").trim());
            }

            strTempVal = p.getProperty("maps_Debug_On").toLowerCase();
            strTempVal = strTempVal.trim();

            if (strTempVal!=null && strTempVal.equals("yes")){
                maps_Debug_On = true;
            } else{
                maps_Debug_On = false;
            }
//MAPS End

//SCB Start
            if (p.getProperty("scb_OutDirectory")==null || p.getProperty("scb_OutDirectory").equals("")){
                scb_OutDirectory = ".";
            } else{
                scb_OutDirectory = p.getProperty("scb_OutDirectory").trim();
            }

            if (p.getProperty("scb_TemplateDirectory")==null || p.getProperty("scb_TemplateDirectory").equals("")){
                scb_TemplateDirectory = ".";
            } else{
                scb_TemplateDirectory = p.getProperty("scb_TemplateDirectory").trim();
            }

            if (p.getProperty("scb_TemplateName")==null || p.getProperty("scb_TemplateName").equals("")){
                scb_TemplateName = "";
            } else{
                scb_TemplateName = p.getProperty("scb_TemplateName").trim();
            }

            if (p.getProperty("scb_ReportHeading")==null || p.getProperty("scb_ReportHeading").equals("")){
                scb_ReportHeading = "MONTHLY ACCOUNT SUMMARY FOR THE MONTH OF <MMM - yyyy>";
            } else{
                scb_ReportHeading = p.getProperty("scb_ReportHeading").trim();
            }

            if (p.getProperty("scb_country_code")==null || p.getProperty("scb_country_code").equals("")){
                scb_country_code = "";
            } else{
                scb_country_code = p.getProperty("scb_country_code").trim();
            }

            if (p.getProperty("scb_carrier_code")==null || p.getProperty("scb_carrier_code").equals("")){
                scb_carrier_code = "";
            } else{
                scb_carrier_code = p.getProperty("scb_carrier_code").trim();
            }

            strTempVal = p.getProperty("scb_Debug_On").toLowerCase();
            strTempVal = strTempVal.trim();

            if (strTempVal!=null && strTempVal.equals("yes")){
                scb_Debug_On = true;
            } else{
                scb_Debug_On = false;
            }
//SCB End

//AstroMSC Start

            if (p.getProperty("AstroMSC_InDirectory")==null || p.getProperty("AstroMSC_InDirectory").equals("")){
                AstroMSC_InDirectory = "";
            } else{
                AstroMSC_InDirectory = p.getProperty("AstroMSC_InDirectory").trim();
            }

            if (p.getProperty("AstroMSC_OutDirectory")==null || p.getProperty("AstroMSC_OutDirectory").equals("")){
                AstroMSC_OutDirectory = "";
            } else{
                AstroMSC_OutDirectory = p.getProperty("AstroMSC_OutDirectory").trim();
            }

            if (p.getProperty("AstroMSC_DoneDirectory")==null || p.getProperty("AstroMSC_DoneDirectory").equals("")){
                AstroMSC_DoneDirectory = "";
            } else{
                AstroMSC_DoneDirectory = p.getProperty("AstroMSC_DoneDirectory").trim();
            }

            if (p.getProperty("AstroMSC_ErrorDirectory")==null || p.getProperty("AstroMSC_ErrorDirectory").equals("")){
                AstroMSC_ErrorDirectory = "";
            } else{
                AstroMSC_ErrorDirectory = p.getProperty("AstroMSC_ErrorDirectory").trim();
            }
//AstroMSC END

        } catch (Exception ex) {
            System.out.print("Process Name (ConfigObject) - " + ex.getClass() + " " + ex.getMessage());
            System.out.print("Please contact the System Administrator...");
            System.exit(1);}
    } // end constructor

    public void write(String strData) {
        try {
            RandomAccessFile raf = new RandomAccessFile(logFile + "Common."+ getDateStamp() + ".log", "rw");
            raf.seek(raf.length());
            raf.writeBytes(getDateStamp() + " " + getTimeStamp() + " " + strData + "\r\n");
            raf.close();
        }
        catch (IOException e) {
            System.out.println("Error opening general log file: " + e);
        }
    }

    public void write(String strData, String strFileName) {
        System.out.println(strData);
        try {
            RandomAccessFile raf = new RandomAccessFile(logFile + strFileName + "." + getDateStamp() + ".log", "rw");
            raf.seek(raf.length());
            raf.writeBytes(getDateStamp() + " " + getTimeStamp() + " " + strData + "\r\n");
            raf.close();
        }
        catch (IOException e) {
            System.out.println("Error opening general log file: " + e);
        }
    }

    public void writeReport(String strData, String strFileName) {
        try {
            RandomAccessFile raf = new RandomAccessFile(logFile + strFileName + ".rpt", "rw");
            raf.seek(raf.length());
            raf.writeBytes(strData + "\r\n");
            raf.close();
        }
        catch (IOException e) {
            System.out.println("Error opening reportfile: " + e);
        }
    }

    public static String getTimeStamp() {
        DateFormat shortTime  = DateFormat.getTimeInstance(DateFormat.MEDIUM);
        String shortTimestamp = shortTime.format(new Date());
        return shortTimestamp;
    }

    public static String getDateStamp() {
        DateFormat shortDate  = new SimpleDateFormat("yyyy-MM-dd");
        String shortDatestamp = shortDate.format(new Date());
        return shortDatestamp;
    }

    private static Properties getEnvironment() throws java.io.IOException {
        Properties env = new Properties();
        String OS = System.getProperty("os.name").toLowerCase();
        if((OS.indexOf("nt") > -1) || (OS.indexOf("windows 2000") > -1 || (OS.indexOf("windows xp") > -1))) {
            Process p = null;
            p = Runtime.getRuntime().exec("cmd.exe /c set");
            BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
            String line;
            while((line = br.readLine()) != null) {
                int idx = line.indexOf('=');
                String key = line.substring(0, idx);
                String value = line.substring(idx + 1);
                env.setProperty(key, value);
            }
        }
        else {
            env.load(Runtime.getRuntime().exec("env").getInputStream());
        }
        return env;
    }

} // end Config

